﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using Maticsoft.DBUtility;
namespace NS.BLL
{
    public partial class Orders
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="orderState"></param>
        /// <returns></returns>
        public DataSet GetOrderListByOrderState(int orderState)
        {
            SqlParameter[] parameters =
                {
                    new SqlParameter("@OrderState", SqlDbType.Int)
                };
            parameters[0].Value = orderState;
            return DbHelperSQL.RunProcedure("GetOrderListByOrderState", parameters, "ds");
        }

        /// <summary>
        /// 根据订单编号获取订单详情
        /// </summary>
        /// <param name="orderID"></param>
        /// <returns></returns>
        public DataSet GetOrderDetailByOrderID(string orderID)
        {
            SqlParameter[] parameters =
                {
                    new SqlParameter("@OrderID", SqlDbType.VarChar)
                };
            parameters[0].Value = orderID;
            return DbHelperSQL.RunProcedure("GetOrderDetailByOrderID", parameters, "ds");
        }

        /// <summary>
        /// 更改订单状态
        /// </summary>
        /// <param name="orderID"></param>
        /// <param name="orderState"></param>
        public void UpdateOrderState(string orderID, int orderState)
        {
            int rowAffect = 0;
            SqlParameter[] parameters =
                {
                    new SqlParameter("@OrderID", SqlDbType.VarChar),
                    new SqlParameter("@OrderState",SqlDbType.Int)
                };
            parameters[0].Value = orderID;
            parameters[1].Value = orderState;
            DbHelperSQL.RunProcedure("UpdateOrderState", parameters, out rowAffect);
        }
    }
}
